package day1105.second;

import day1105.common.MyUtil;
import day1105.common.Student;

import java.util.List;

import static day1105.common.MyUtil.printLine;

/**
 * @author Mr.ma
 * @since 2022/11/6 16:05
 **/
public class LimitTest {
    public static void main(String[] args) {
        List<Student> studentList = MyUtil.createStudentList();
        studentList.stream().forEach(System.out::println);
        printLine("展示成绩第一的学生信息");
        studentList.stream().sorted((s1,s2) -> s2.getScore().compareTo(s1.getScore()))
                .limit(1).forEach(System.out::println);
        printLine("展示倒数前三名的学生信息");
        studentList.stream().sorted((s1,s2) -> s1.getScore().compareTo(s2.getScore()))
                .limit(3).forEach(System.out::println);
    }
}
